package com.epfresh.supplier.entity;

import com.epfresh.supplier.constant.Constant;

/**
 * Created by wzh on 2016/5/13.
 */
public class PriceSetting {


    private String id;
    private String cityName;
    private String cityId;
    private String code;
    private String moq = "";

    private float price;
    private String estimatedArrivalTime;
    private String services;
    private boolean isSelect;
    //0,未选中，>0,选中，<0，不存在
    private int statusDeliverySelect = -1;
    private int statusPickUpSelect = -1;
    private int statusOnlineSelect = -1;
    private int statusOfflineSelect = -1;

    private int cityPosition = -1;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public int getCityPosition() {
        return cityPosition;
    }

    public void setCityPosition(int cityPosition) {
        this.cityPosition = cityPosition;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMoq() {
        return moq;
    }

    public void setMoq(String moq) {
        this.moq = moq;
    }

    public int getStatusDeliverySelect() {
        return statusDeliverySelect;
    }

    public void setStatusDeliverySelect(int statusDeliverySelect) {
        this.statusDeliverySelect = statusDeliverySelect;
    }

    public int getStatusPickUpSelect() {
        return statusPickUpSelect;
    }

    public void setStatusPickUpSelect(int statusPickUpSelect) {
        this.statusPickUpSelect = statusPickUpSelect;
    }

    public int getStatusOnlineSelect() {
        return statusOnlineSelect;
    }

    public void setStatusOnlineSelect(int statusOnlineSelect) {
        this.statusOnlineSelect = statusOnlineSelect;
    }

    public int getStatusOfflineSelect() {
        return statusOfflineSelect;
    }

    public void setStatusOfflineSelect(int statusOfflineSelect) {
        this.statusOfflineSelect = statusOfflineSelect;
    }

    public boolean isSelect() {
        return isSelect;
    }

    public void setSelect(boolean select) {
        isSelect = select;
    }

    public String getCityName() {
        return cityName;
    }

    public void setCityName(String cityName) {
        this.cityName = cityName;
    }

    public float getPrice() {
        return price;
    }

    public void setPrice(float price) {
        this.price = price;
    }

    public String getServicesStr() {
        return services;
    }

    public void setServices(String services) {
        this.services = services;
    }

    public String getEstimatedArrivalTime() {
        return estimatedArrivalTime;
    }

    public void setEstimatedArrivalTime(String estimatedArrivalTime) {
        this.estimatedArrivalTime = estimatedArrivalTime;
    }

    public String getCityId() {
        return cityId;
    }

    public void setCityId(String cityId) {
        this.cityId = cityId;
    }

    public void setServices(){
        this.services = getServices();
    }

    public String getServices() {
        String s = "";
        int i = 0;
        //选择了配送方式
        if (statusDeliverySelect > 0) {
            i++;
            s += Constant.EXPRESS_DELIVERY;
        }

        if (statusPickUpSelect > 0) {
            if (i == 1) {
                s += ",";
            }
            s += Constant.SELF_DELIVERY;
            i++;
        }

        if (statusOnlineSelect > 0) {
            if (i > 0) {
                s += ",";
            }
            s += Constant.ON_LINE_PAYMENT;
            i++;
        }
        if (statusOfflineSelect > 0) {
            s += ",";
            s += Constant.CASH_ON_DELIVERY;
        }
        return s;
    }

    //选择了配送方式
    public boolean hasDelivery() {
        return statusDeliverySelect > 0 || statusPickUpSelect > 0;
    }

    //选择了支付方式
    public boolean hasPayWay() {
        return statusOnlineSelect > 0 || statusOfflineSelect > 0;
    }

    public void resultSelectStatus(){
        if (services != null){
            if (services.contains(Constant.EXPRESS_DELIVERY)){
                statusDeliverySelect = 1;
            }
            if (services.contains(Constant.SELF_DELIVERY)){
                statusPickUpSelect = 1;
            }
            if (services.contains(Constant.ON_LINE_PAYMENT)){
                statusOnlineSelect = 1;
            }
            if (services.contains(Constant.CASH_ON_DELIVERY)){
                statusOfflineSelect = 1;
            }

        }
    }

    @Override
    public String toString() {
        return "PriceSetting{" +
                "id='" + id + '\'' +
                ", cityName='" + cityName + '\'' +
                ", cityId='" + cityId + '\'' +
                ", code='" + code + '\'' +
                ", moq='" + moq + '\'' +
                ", price=" + price +
                ", estimatedArrivalTime='" + estimatedArrivalTime + '\'' +
                ", services='" + services + '\'' +
                ", isSelect=" + isSelect +
                ", statusDeliverySelect=" + statusDeliverySelect +
                ", statusPickUpSelect=" + statusPickUpSelect +
                ", statusOnlineSelect=" + statusOnlineSelect +
                ", statusOfflineSelect=" + statusOfflineSelect +
                ", cityPosition=" + cityPosition +
                '}';
    }
}
